var dashboard = {
    init : function() {
        var me = this;
        common.screenAutoFit();
        $(window).resize(function() {
            common.screenAutoFit();
        });
        me.pieInit();
        me.gaugesInit();
        me.lineInit();
        me.barInit();
        me.heapInit();
    },
    gaugesInit : function() {

        if($('#g1').length){
            charts.gauge('g1',{value:  0.45, style: 0 });
        }
        // me.gaugeOne('pie23',{value:  0.65, style: 1 });
        // me.gaugeOne('pie33',{value:  0.48, style: 2 });
    },
    pieInit : function(){
        if($('#p1').length){
            charts.pie('p1',[
                {value: 547 ,name: '男'},
                {value: 274, name: '女'}
            ]);
        }
        if($('#p2').length){
            charts.pie('p2',[
                {value: 747 ,name: '男'},
                {value: 241, name: '女'}
            ]);
        }
        if($('#p3').length){
            charts.pie('p3',[
                {value: 747 ,name: '一年级'},
                {value: 874, name: '二年级'},
                {value: 441, name: '三年级'},
                {value: 124, name: '四年级'},
                {value: 647, name: '五年级'},
                {value: 241, name: '六年级'},
            ]);
        }
        if($('#p4').length){
            charts.pie('p4',[
                {value: 345 ,name: '一年级'},
                {value: 474, name: '二年级'},
                {value: 641, name: '三年级'},
                {value: 154, name: '四年级'},
                {value: 477, name: '五年级'},
                {value: 211, name: '六年级'},
            ]);
        }

    },
    lineInit(){
        if($('#line1').length){
            charts.line('line1',{
                title: '本学期每天学校跳绳数 (w）',
                style: 0,
                dataX: ['12.21', '12.22', '12.23', '12.24', '12.25', '12.26', '12.27', '12.28'],
                dataY: [220, 182, 191, 134, 150, 120, 110, 125 ]
            });
        }
        if($('#line2').length){
            charts.line('line2',{
                title: '本学期每天学校跳绳时长 (h)',
                style: 1,
                dataX: ['12.21', '12.22', '12.23', '12.24', '12.25', '12.26', '12.27', '12.28'],
                dataY: [120, 110, 125, 145, 122, 165, 122, 220]
            });
        }
    },
    barInit(){
        if($('#bar1').length){
            charts.bar('bar1',{
                title: '本学期跳绳年级计划完成情况',
                style: 0,
                dataX: ['一年级', '二年级', '三年级', '四年级', '五年级','六年级'],
                dataY: [90,88,75,73,65,54]
            });
        }
    },
    heapInit(){
        if($('#h1').length){
            charts.heap('h1',{
                area: ['1年级', '2年级', '3年级', '4年级', '5年级'],
                legend: ['王者', '钻石', '铂金', '黄金', '白银', '青铜'],
                data: [
                    [320, 302, 301, 334, 390],
                    [100, 150, 320, 302, 301],
                    [455, 321, 100, 50, 320],
                    [341, 330, 320, 121, 127],
                    [334, 390, 204, 320, 74],
                    [274, 201, 310, 78, 120],
                ]
            });
        }
    }
}

$(function () {
    dashboard.init();
});